<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>


<html>
<f:view>
    <head><title>Simple jsp page</title></head>
    <body>

    <h:dataTable value="#{jpa.listUzytkownik}" var="user">
        <h:column>
            <f:facet name="header">
                <h:outputText value="Nazwa uzytkownika"/>
            </f:facet>
            <h:outputText value="#{user.nazwa}"/>
        </h:column>
        <h:column>
            <f:facet name="header">
                <h:outputText value="Profil"/>
            </f:facet>
            <h:outputText value="#{user.profil}"/>
        </h:column>
        <h:column>
            <f:facet name="header">
                <h:outputText value="Usun"/>
            </f:facet>
            <h:commandLink id="Delete" actionListener="#{jpa.usunUsera}">
                <h:outputText value="Delete"/>
                <f:param id="deleteId" name="id" value="#{user}"/>
            </h:commandLink>
        </h:column>
    </h:dataTable>
        <h:form>
        <h:inputText value="#{jpa.nowyUserNazwa}"/>
        <h:selectOneMenu value="#{jpa.nowyUserProfil}">
            <f:selectItems value="#{jpa.profilItems}" />
        </h:selectOneMenu>
        <h:commandButton action="#{jpa.dodajUsera}" value="dodaj usera"/>
    </h:form>

    <br/>
    <br/>

    <h:dataTable value="#{jpa.listProfil}" var="profil">
        <h:column>
            <f:facet name="header">
                <h:outputText value="Profil"/>
            </f:facet>
            <h:outputText value="#{profil.nazwa}" />
        </h:column>
        <h:column>
            <f:facet name="header">
                <h:outputText value="Usun"/>
            </f:facet>
            <h:commandLink id="Delete" actionListener="#{jpa.usunProfil}">
                <h:outputText value="Delete"/>
                <f:param id="deleteId" name="id" value="#{profil}"/>
            </h:commandLink>
        </h:column>
    </h:dataTable>

    <h:form>
        <h:inputText value="#{jpa.nowyProfil}"/>
        <h:commandButton action="#{jpa.dodajProfil}" value="dodaj profil"/>
    </h:form>

    </body>
</f:view>
</html>